# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from backend.sku_api.model import sku_info_manager


class Sku(object):
    """
    SKU信息
    """

    # TODO：对SKU Info筛选依赖业务服务品类信息
    def __init__(self, business_service_cate):
        self.skuinfo_list = sku_info_manager.select()
        self.skuinfos = dict()
        self.self_sku_list = list()
        self.compete_sku_list = list()

    def set_skuinfo_by_sku_list(self, sku_list=[]):
        if len(sku_list) > 0:
            for sku in self.skuinfo_list:
                if sku.name in sku_list:
                    self.skuinfos[sku.name] = {
                        "id": sku.id,
                        "name": sku.name,
                        "brand": sku.brand,
                        "shape": sku.shape,
                        "number": sku.number,
                        "default_img": sku.default_img,
                        "spec": sku.spec,
                        "unitprice": sku.unitprice,
                        "is_product": sku.is_product,
                        "cate": sku.cate,
                    }
                    if sku.is_product:
                        self.self_sku_list.append(sku.name)
                    else:
                        self.compete_sku_list.append(sku.name)
